/*
 * create:2016年5月2日 上午11:00:49
 * author:wangds  
 */
package com.cxkj.shop.biz;

import com.cxkj.shop.form.DefaultDeliveryBuilder;
import com.cxkj.shop.form.Delivery;
import com.cxkj.shop.form.DeliveryBuilder;

import net.wangds.comp.business.http.AbstractBaseHttpInteractionBusiness;

/**
 * .
 * @author wangds
 *
 */
public abstract class AbstractBaseDeliveryHttpInteractionBusiness<T,R> extends AbstractBaseHttpInteractionBusiness<T, Delivery> {

  /*
   * @see net.wangds.comp.business.http.AbstractBaseHttpInteractionBusiness#process(java.lang.Object)
   * @author wangds 2016年5月2日 上午11:01:28.
   */
  @Override
  protected Delivery process(T param) throws Exception {

    Delivery res = null;
    DeliveryBuilder<R> builder = null;
    try{
      builder = DefaultDeliveryBuilder.getInstance();
      builder.init();
      builder.setData(processBiz(param));
      builder.success();
    }catch(Exception e){
      builder.fail();
      this.getLogger().error(e.getLocalizedMessage(),e);
    }finally{
      if(builder!=null){
        res = builder.toDelivery();
        builder.clear();
      }
    }
    return res;
  
  }

  /**
   * .
   * @author wangds 2016年5月2日 上午11:03:35.
   * @param param .
   * @return .
   */
  protected abstract R processBiz(T param) throws Exception;

}
